package org.eae.eldf.service.sys.impl;

import java.util.List;

import org.eae.eldf.dao.sys.ISysMenuDao;
import org.eae.eldf.dao.sys.impl.SysMenuDaoImpl;
import org.eae.eldf.entity.sys.SysMenu;
import org.eae.eldf.framework.persistence.Criteria;
import org.eae.eldf.framework.service.BaseServiceImpl;
import org.eae.eldf.service.sys.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class SysMenuServiceImpl  extends BaseServiceImpl<SysMenu> implements SysMenuService{

	private ISysMenuDao sysMenuDao;

	@Autowired
	public void setSysMenuDao(SysMenuDaoImpl sysMenuDao) {
		this.sysMenuDao = sysMenuDao;
		this.dao = sysMenuDao;
	}


	@Override
	public void insertMenu(SysMenu menu) {
		if(menu.getParentid()!=null){
			//更新父级菜单 bisleaf为0
			this.update(Criteria.create(SysMenu.class).set("bisleaf", 0).where("sysMenuId", new Object[]{menu.getParentid()}));
		}
		this.insert(menu);
		
	}

	@Override
	public List<SysMenu> queryList() {
		// TODO Auto-generated method stub
		return this.queryList(Criteria.create(SysMenu.class));
	}

	@Override
	public List<SysMenu> queryMenuList(SysMenu sysMenu) {
		// TODO Auto-generated method stub
		return sysMenuDao.queryMenuList(sysMenu);
	}
	
	
	
}
